package net.pimpas.security.serviceprovider.auth.login.principal;

public class PrincipalImpl implements Principal {
	
	private static final long serialVersionUID = -2779083787654934211L;
	private String name;
	private Object internal;
	
	public PrincipalImpl(String name, Object ob) {
		this.setName(name);
		this.internal = ob;
	}

	public String getName() {
		return this.name;
	}

	public Object getInternal() {
		return internal;
	}

	public void setInternal(Object internal) {
		this.internal = internal;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Principal) {
			Principal p1 = (Principal) obj;
			return this.getName().equalsIgnoreCase(p1.getName());
		}
		return false;
	}
	
	@Override
	public int hashCode() {
		return this.getInternal().hashCode();
	}

	public Object getObject() {
		return this.getInternal();
	}
}